package com.javalong.androidmorning.wechat.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.javalong.androidmorning.dao.ArticleDao;
import com.javalong.androidmorning.pojo.Article;

/**
 * 主要对微信的请求及返回数据作处理
 * 
 * @author Administrator
 *
 */
@Service
public class ArticleService {

	@Autowired
	private ArticleDao articleDao;

	public List<Article> getList(int page, int pageSize) {
		return articleDao.findAll(page * pageSize, pageSize);
	}

	public void delete(int id) {
		articleDao.delete(id);
	}

	public void save(Article article) {
		Date now = new Date();
		article.setCreateAt(now);
		article.setUpdateAt(now);
		articleDao.save(article);
	}

	public int getCount() {
		return articleDao.getCount();
	}

	public void update(Article article) {
		Date now = new Date();
		article.setUpdateAt(now);
		articleDao.update(article);
	}

	public Article findById(int id) {
		return articleDao.findById(id);
	}

	public List<Article> findArticleByResid(int resId) {
		return articleDao.findArticleByResid(resId);
	}
}
